package com.ftg.learn.psi.controller;


import com.ftg.learn.psi.Dto.SalesParam;
import com.ftg.learn.psi.entity.SalesOrder;
import com.ftg.learn.psi.service.ISalesOrderService;
import com.ftg.learn.psi.utils.ResEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 销售订单表 前端控制器
 * </p>
 *
 * @author guoBingTong
 * @since 2022-05-18
 */
@RestController
@RequestMapping("/psi/sales-order")
public class SalesOrderController {

    @Autowired
    ISalesOrderService iSalesOrderService;

    /**
     * 添加销售订单表,同时添加销售订单明细表并削减商品的库存。
     * @param salesParam
     * @return
     */
    @PostMapping("/insert")
    public ResEntity insertPurchaseOrder(@RequestBody SalesParam salesParam){
        return iSalesOrderService.suoHaHa(salesParam) ?
                new ResEntity().OK() : new ResEntity().Failure();
    }

    @PostMapping("/insert1")
    public ResEntity insertPurchaseOrder1(@RequestBody SalesParam salesParam){
        return iSalesOrderService.insertSalesOrder(salesParam) ?
                new ResEntity().OK() : new ResEntity().Failure();
    }

}
